<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/

get_config_keytable("date_workdate");
empty($do) && $do = 'list';
if ($do == 'list') {
	//列表信息 
	$wheresql = '';
	$page = max(1, getGP('page','G','int'));
	$pagesize = 20;
	$offset = ($page - 1) * $pagesize;
	$url = 'admin.php?ac=index&fileurl=workdate';

	if ($keyword = getGP('keyword','G')) {
		$wheresql .= " AND title LIKE '%$keyword%'";
		$url .= '&keyword='.rawurlencode($keyword);
	}
	//时间
	$vstartdate = getGP('vstartdate','G');
	$venddate = getGP('venddate','G');
	if ($vstartdate!='' && $venddate!='') {
		$wheresql .= " AND (startdate>='".$vstartdate."' and enddate<='".$venddate."')";
	$url .= '&vstartdate='.$vstartdate.'&venddate='.$venddate;
	}
	if ($fatherid = getGP('otype','G','int')) {
		$wheresql .= " AND otype = $fatherid";
		$url .= '&otype='.$fatherid;	
	}
	if(!is_superadmin()){
	if (getGP('type','G','int')=='1') {
		$wheresql .= " AND uid = $_USER->id";
		$url .= '&type='.getGP('type','G','int');	
	}else{
	$wheresql .= " AND type ='公开' and uid != $_USER->id";
	}
	}
	
	$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."workdate WHERE 1 $wheresql");
     $sql = "SELECT * FROM ".DB_TABLEPRE."workdate WHERE 1 $wheresql ORDER BY id desc LIMIT $offset, $pagesize";
	$result = $db->fetch_all($sql);

	include_once('template/index.php');

} elseif ($do == '删 除') {
if (check_purview('date_workdate_delete')!='1')

get_config_keytable("date_workdate_delete");
	$idarr = getGP('id','P','array');
	foreach ($idarr as $id) {
	$db->query("DELETE FROM ".DB_TABLEPRE."workdate WHERE id = '$id'");
	//db->query("DELETE FROM ".DB_TABLEPRE."user_view WHERE uid = '$id'");
	$content=$id;
	$title='删除日程信息';
	get_oa_log_dbadd($id,$content,$title,10,$_USER->id);	
	}
	goto_page('admin.php?ac=index&fileurl=workdate&type=1&message=1');

} 



//读部门

?>